﻿<html>
  <head>
    <script type="text/javascript" src="Builder.js"></script>
    <script type="text/javascript" src="More.js"></script>
    <script type="text/javascript" src="Simple.js"></script>
    <script type="text/javascript" src="../content/namespace.js"></script>
    <script type="text/javascript" src="../content/utils.js"></script>
  </head>
  <body>
    <pre id="test">
      <script type="text/javascript">
      	plan({ tests: 97 });
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("  ").words, [], "getIncludeExcluded words 0");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite").words, [], "getIncludeExcluded words 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox").words, [], "getIncludeExcluded words 2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"\"").words, [""], "getIncludeExcluded words 3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\" \"").words, [" "], "getIncludeExcluded words 4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("-").words, [], "getIncludeExcluded words 5");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-notexclude \"").words, ["-notexclude "], "getIncludeExcluded words 6");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("- s").words, [], "getIncludeExcluded words 7");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"- s\"").words, ["- s"], "getIncludeExcluded words 8");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"add\" \"s\"").words, ["add", "s"], "getIncludeExcluded words 9");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"add\" \"- s\"").words, ["add", "- s"], "getIncludeExcluded words 10");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"add\" on \"- s\"").words, ["add", "- s"], "getIncludeExcluded words 11");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\" on \"add\"").words, ["-","add"], "getIncludeExcluded words 12");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn\"t \"add\" owner\"s ").words, ["add"], "getIncludeExcluded words 13");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn't \"add\" owner's ").words, ["add"], "getIncludeExcluded words 14");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn't \"add\" owner's \"-\"").words, ["add","-"], "getIncludeExcluded words 15");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\" doesn't \"add\" owner's").words, ["-","add"], "getIncludeExcluded words 16");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\"    doesn't   \"add\"  owner's").words, ["-","add"], "getIncludeExcluded words 17");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox").optional, ["sqlite","firefox"], "getIncludeExcluded optional 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("- s").optional, ["-", "s"], "getIncludeExcluded optional 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite").optional, ["sqlite"], "getIncludeExcluded optional 2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("  ").optional, [], "getIncludeExcluded optional 3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("-").optional, ["-"], "getIncludeExcluded optional 4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("- add on").optional, ["-", "add", "on"], "getIncludeExcluded optional 5");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("- \"add\" on").optional, ["-", "on"], "getIncludeExcluded optional 6");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\" on \"add\"").optional, ["on"], "getIncludeExcluded optional 7");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn't \"add\"").optional, ["doesn't"], "getIncludeExcluded optional 8");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn't owner's").optional, ["doesn't","owner's"], "getIncludeExcluded optional 9");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn\"t owner\"s").optional, ["doesn\"t","owner\"s"], "getIncludeExcluded optional 10");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn\"t \"add\" owner\"s ").optional, ["doesn\"t","owner\"s"], "getIncludeExcluded optional 11");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\" \"add\" on").optional, ["on"], "getIncludeExcluded optional 12");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\"   \"add\"  on").optional, ["on"], "getIncludeExcluded optional 13");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite").excluded, [], "getIncludeExcluded excluded 0");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite -firefox").excluded, ["firefox"], "getIncludeExcluded excluded 1");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite -\"google\"").excluded, ["google"], "getIncludeExcluded excluded 2");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite -g1 -g2").excluded, ["g1","g2"], "getIncludeExcluded excluded 3");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite -\"g1 g2\"").excluded, ["g1 g2"], "getIncludeExcluded excluded 4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite -\"g1 g2\" -g3").excluded, ["g1 g2","g3"], "getIncludeExcluded excluded 5");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("-\"g1 g2\" -g3").excluded, ["g1 g2","g3"], "getIncludeExcluded excluded 6");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("-\"g1 g2\" sqlite -g3").excluded, ["g1 g2","g3"], "getIncludeExcluded excluded 7");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("-\"\"").excluded, [""], "getIncludeExcluded excluded 8");
        isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("-\" \"").excluded, [" "], "getIncludeExcluded excluded 9");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\" on \"add\"").excluded, [], "getIncludeExcluded excluded 10");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\" on -\"g1 \" -g2 \"add\"").excluded, ["g1 ","g2"], "getIncludeExcluded excluded 11");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("-g1 \"-\" on \"add\"").excluded, ["g1"], "getIncludeExcluded excluded 12");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("\"-\"     on    -\"g1   \" -g2  \"add\"").excluded, ["g1   ","g2"], "getIncludeExcluded excluded 13");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox site:test.com").site, ["test.com"], "getIncludeExcluded site 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("site:onlysite").site, ["onlysite"], "getIncludeExcluded site 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("site:ab site:.com").site, ["ab",".com"], "getIncludeExcluded site 2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("site:ab   site:.com").site, ["ab",".com"], "getIncludeExcluded site 3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox time:02/02/2010-").time, [{since: new Date("02/02/2010").getTime(), till:Number.MAX_VALUE}], "getIncludeExcluded time 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox time:02/02/2010-02/03/2011").time, [{since: new Date("02/02/2010").getTime(), till: new Date("02/03/2011").getTime()}], "getIncludeExcluded time 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox time:-02/02/2010").time, [{since: -1, till:new Date("02/02/2010").getTime()}], "getIncludeExcluded time 2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn\"t \"add\" time:02/02/2010-02/03/2011 owner\"s").time, [{since: new Date("02/02/2010").getTime(), till:new Date("02/03/2011").getTime()}], "getIncludeExcluded time 3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("doesn\"t   \"add\"  time:02/02/2010-02/03/2011 owner\"s").time, [{since: new Date("02/02/2010").getTime(), till:new Date("02/03/2011").getTime()}], "getIncludeExcluded time 4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox time:02/02/2010-fsa").time, [{since: new Date("02/02/2010").getTime(), till:Number.MAX_VALUE}], "getIncludeExcluded time 5");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox time:--").time, [], "getIncludeExcluded time -1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox time:02/02/2010").time, [], "getIncludeExcluded time -2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getIncludeExcluded("sqlite firefox time:02/02/2010=09/02/2010").time, [], "getIncludeExcluded time -3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeHaveSubstring({arr:["job","jobs"],freq:function(){var a=[];a["job"]=0.06;a["jobs"]=0.05;return a;}()}), {arr:["job"],freq:function(){var a=[];a["job"]=0.11;return a;}()}, "removeHaveSubstring 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeHaveSubstring({arr:["job","jobs","home","homeowner"],freq:function(){var a=[];a["job"]=0.06;a["jobs"]=0.05;a["home"]=0.03;a["homeowner"]=0.005;return a;}()}), {arr:["job","home"],freq:function(){var a=[];a["job"]=0.11;a["home"]=0.03+0.005;return a;}()}, "removeHaveSubstring 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.uniqueArray(["job","job","jobs","home","home","homeowner"]),["job","jobs","home","homeowner"], "uniqueArray 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.uniqueArray(["job","job","jobs","home","home","homeowner"], true).arr,["job","jobs","home","homeowner"], "uniqueArray 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.uniqueArray(["job","job","jobs","home","home","homeowner"], true).repeated, ["job","home"], "uniqueArray 1.0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.uniqueArray(["job","job","jobs","home","home","homeowner"], true).freq["job"],(2+0.0)/6, "uniqueArray 1.1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.uniqueArray(["job","job","jobs","home","home","homeowner"], true).freq["jobs"],(1+0.0)/6, "uniqueArray 1.2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.uniqueArray(["job","job","jobs","home","home","homeowner"], true).freq["home"],(2+0.0)/6, "uniqueArray 1.3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.uniqueArray(["job","job","jobs","home","home","homeowner"], true).freq["homeowner"],(1+0.0)/6, "uniqueArray 1.4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeEmptyLine("s\n\nt\n\n\na"),"s\nt\na", "removeEmptyLine 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.getAllChnWords(["没还","欠钱"],["欠钱塞拉炯桑"]), ["欠钱","塞拉炯桑"], "getAllChnWords 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(6,[1,2,4,5]),{exist:false,arr:[1,2,4,5,6]},"divInsert non-exist in len4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(0,[1,2,4,5]),{exist:false,arr:[0,1,2,4,5]},"divInsert non-exist small in len4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(3,[1,2,4,5]),{exist:false,arr:[1,2,3,4,5]},"divInsert non-exist mid in len4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(1,[1,2,4,5]),{exist:true,arr:[1,2,4,5]},"divInsert exist small in len4 ");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(2,[1,2,4,5]),{exist:true,arr:[1,2,4,5]},"divInsert exist in len4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(5,[1,2,4,5]),{exist:true,arr:[1,2,4,5]},"divInsert exist large in len4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(1,[1,2,4]),{exist:true,arr:[1,2,4]},"divInsert exist small in len3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(2,[1,2,4]),{exist:true,arr:[1,2,4]},"divInsert exist in len3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(4,[1,2,4]),{exist:true,arr:[1,2,4]},"divInsert exist large in len3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(3,[1,2,4]),{exist:false,arr:[1,2,3,4]},"divInsert non-exist in len3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(0,[1,2,4]),{exist:false,arr:[0,1,2,4]},"divInsert non-exist small in len3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(5,[1,2,4]),{exist:false,arr:[1,2,4,5]},"divInsert non-exist large in len3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(1,[1,2]),{exist:true,arr:[1,2]},"divInsert exist small in len2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.divInsert(2,[1,2]),{exist:true,arr:[1,2]},"divInsert exist in len2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("\"sqlite"),"sqlite","removeNonWord 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("\"sqlite\""),"sqlite","removeNonWord 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("sqlite,"),"sqlite","removeNonWord 2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("\"sqlite\"!"),"sqlite","removeNonWord 3");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("sqlite\',"),"sqlite","removeNonWord 4");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("sql@it.et"),"sql@it.et","removeNonWord keep 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("it.et"),"it.et","removeNonWord keep 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("sql@it.et\',"),"sql@it.et","removeNonWord complex 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("\"sql@it.et\',"),"sql@it.et","removeNonWord complex 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.removeNonWord("!sql@it.et"),"sql@it.et","removeNonWord complex 2");
	isDeeply(com.wuxuan.fromwheretowhere.utils.subArray([1,2,3,4,5],1,3),[2,3],"subArray 0");
	isDeeply(com.wuxuan.fromwheretowhere.utils.subArray([1,2,3,4,5],1,6),[2,3,4,5],"subArray 1");
	isDeeply(com.wuxuan.fromwheretowhere.utils.subArray([1,2,3,4,5],-1,3),[1,2,3],"subArray 2");
        //isDeeply([1,2].concat([3,4]), [1,2,3,4], "concat");
      </script>
    </pre>
  </body>
</html>
